feat: enforce teamMin/teamMax limits in SubmissionForm - #432
Conversation
|
@Anuoluwapo25 is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe submission form now enforces team size constraints by validating maximum capacity when adding invitees and minimum requirements before progression. The Invite Members section displays a badge showing current vs. maximum members, warnings for undersized teams, and disables inputs when capacity is reached. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/hackathons/submissions/SubmissionForm.tsx (1)
790-817: Extract shared team-capacity booleans to reduce duplication.
invitees.length + 1 >= currentHackathon.teamMaxand related calculations are repeated in multiple JSX props/branches. Centralizing intoteamSize,isAtTeamMax, andmembersNeededwill reduce drift risk and improve readability.♻️ Suggested refactor
+ const teamSize = invitees.length + 1; + const isAtTeamMax = !!( + currentHackathon && teamSize >= currentHackathon.teamMax + ); + const membersNeeded = currentHackathon + ? Math.max(currentHackathon.teamMin - teamSize, 0) + : 0; ... - invitees.length + 1 >= currentHackathon.teamMax + isAtTeamMax ... - {invitees.length + 1} / {currentHackathon.teamMax}{' '} + {teamSize} / {currentHackathon.teamMax}{' '} members ... - invitees.length + 1 < currentHackathon.teamMin && ( + membersNeeded > 0 && ( <p className='text-xs text-yellow-500'> Minimum {currentHackathon.teamMin} members required - — add{' '} - {currentHackathon.teamMin - (invitees.length + 1)}{' '} + — add {membersNeeded}{' '} more to proceed. </p> )} ... - disabled={ - !!( - currentHackathon && - invitees.length + 1 >= currentHackathon.teamMax - ) - } + disabled={isAtTeamMax} ... - disabled={ - !!( - currentHackathon && - invitees.length + 1 >= currentHackathon.teamMax - ) - } + disabled={isAtTeamMax} ... - currentHackathon && - invitees.length + 1 >= currentHackathon.teamMax + isAtTeamMax ? 'Team is at maximum capacity' : 'Add member' }Also applies to: 827-832, 842-847, 856-861, 867-879
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/hackathons/submissions/SubmissionForm.tsx` around lines 790 - 817, Compute shared team-capacity values once and reuse them: add local constants (e.g., teamSize = invitees.length + 1, isAtTeamMax = teamSize >= currentHackathon.teamMax, membersNeeded = Math.max(0, currentHackathon.teamMin - teamSize)) near the top of the component or inside the SubmissionForm render so all JSX uses these variables instead of repeating invitees.length + 1 and arithmetic; update the Badge className condition, the Badge text, and all conditional renders that reference teamMin/teamMax (the places currently using invitees.length + 1) to use teamSize, isAtTeamMax, and membersNeeded (keeping currentHackathon null checks as before).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/hackathons/submissions/SubmissionForm.tsx`:
- Around line 459-469: The current validation only enforces
currentHackathon.teamMin when creating a new team and skips the myTeam branch,
so existing teams can bypass minimum-size checks; update the submission flow in
SubmissionForm (the handler that checks invitees and myTeam) to apply the same
minimum-member validation for both new-team and myTeam branches by checking
currentHackathon.teamMin against the total members (invitees.length + 1 or the
existing team member count) before allowing submission, and surface the same
toast.error message when the team is below teamMin.
---
Nitpick comments:
In `@components/hackathons/submissions/SubmissionForm.tsx`:
- Around line 790-817: Compute shared team-capacity values once and reuse them:
add local constants (e.g., teamSize = invitees.length + 1, isAtTeamMax =
teamSize >= currentHackathon.teamMax, membersNeeded = Math.max(0,
currentHackathon.teamMin - teamSize)) near the top of the component or inside
the SubmissionForm render so all JSX uses these variables instead of repeating
invitees.length + 1 and arithmetic; update the Badge className condition, the
Badge text, and all conditional renders that reference teamMin/teamMax (the
places currently using invitees.length + 1) to use teamSize, isAtTeamMax, and
membersNeeded (keeping currentHackathon null checks as before).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
components/hackathons/submissions/SubmissionForm.tsx
There was a problem hiding this comment.
Kindly make these changes:
-
In
SubmissionForm.tsx, the minimum team size validation (teamMin) currently only applies when creating a new team, allowing submissions with existing teams (myTeam) to bypass the check. The submission logic should enforce the same minimum-member validation for both new and existing teams and display the sametoast.errormessage when the team size is belowteamMin. -
Refactor the code to avoid repeating team-size calculations by introducing shared constants such as
teamSize,isAtTeamMax, andmembersNeeded, and reuse them across the component (badge display, conditions, and UI logic). -
The max team size field should be derived from the hackathon rules data and should not be editable. It should control how many open roles a user can create.
-
The CodeRabbit feedback was marked as resolved without an accompanying fix commit. Please ensure all corrections are implemented in code and backed by a verifiable commit rather than resolving comments manually.
-
Make a screen record of creating a team post using an ongoing hackathon.
|
I’m just seeing this correction
I have actually been waiting for your feedback since it wasn’t merged
…On Thu, Mar 5, 2026 at 8:05 PM Nnaji Benjamin ***@***.***> wrote:
Closed #432 <#432>.
—
Reply to this email directly, view it on GitHub
<#432 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/A55OV7UENPS5UKPFMDHIHE34PHFWXAVCNFSM6AAAAACWEZTZ2KVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRTGMYDQNJWGE3DGOA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
###Overview
This PR enforces hackathon team size constraints (teamMin, teamMax) directly within the SubmissionForm UI.
Users can no longer:
-Proceed with a team smaller than the configured minimum
-Invite members beyond the configured maximum
-This ensures organizer-defined limits are strictly respected at the interface level before submission.
Summary by CodeRabbit
New Features
UX Improvements
closes Enforce Team Size Limits (
teamMin,teamMax) #405